package com.dao.impl;

import com.dao.CheckingDao;
import com.domain.Checking;
import com.factory.OfficeFactory;

import java.util.ArrayList;

public class CheckingDaoImpl implements CheckingDao {

    @Override

    public Boolean save(Checking checking) {
        String sql = "insert into employees_attendance values(null,?,?,?,?,?)";

        return OfficeFactory.update(sql,checking.getUname(),checking.getUage(),checking.getUposition(),checking.getDate(),
                checking.getAttendance());
    }

    @Override
    public Boolean delete(int id) {
        String sql = "delete From employees_attendance where uid = ?";
        return OfficeFactory.update(sql,id);
    }

    @Override
    public ArrayList<Checking> select() {
        String sql = "select * from employees_attendance";
        return OfficeFactory.select(new Checking(),sql);
    }

    @Override
    public Boolean update(Checking checking) {
        String sql = "update employees_attendance set uname = ? , uage = ? , uposition = ? ," +
                "date = ? , attendance = ? where uid = ?";

        return OfficeFactory.update(sql,checking.getUname(),checking.getUage(),checking.getUposition(),
                checking.getDate(),checking.getAttendance(),checking.getUid());
    }
}
